package demo01;

public class zuoye05 {
    public static void main(String[] args) {
        String input = "abcdefg";
        int start = 2;
        int end = 6;
        String result = reverseSubstring(input, start, end);
        System.out.println(result);
    }

    public static String reverseSubstring(String input, int start, int end) {
        StringBuilder sb = new StringBuilder(input);
        sb.reverse();
        String reversed = sb.toString();
        return input.substring(0, start) + reversed.substring(start, end) + input.substring(end);
    }
}
